feat(@angular/build): migrate i18n inliner to oxc-parser + magic-string#33601
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces Babel with OXC and Magic-String in the i18n inliner worker to optimize translation inlining. Feedback is provided regarding template literal reconstruction, where carriage returns could be normalized to line feeds and corrupt translations; a suggestion is made to use JSON.stringify for robust escaping.
This refactors the i18n translation and locale inlining in the ESBuild pipeline to use `oxc-parser` and `magic-string` instead of `@babel/core`. By using the lightweight AST and precise token spans provided by OXC, we are able to perform `$localize` inlining and locale name replacements via targeted `magic-string` overwrites in-place. This completely removes the dependency on `@babel/core` and the custom/upstream Babel plugins in the worker, yielding faster startup times and significant compile-time speedups for localized builds.
cc6d3a3 to
29fb055
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
Amazing, thanks for working on this! Is it planned for the next release (or pre-release) so I can test it out? (I opened #33554 ) |
|
Releases typically occur on Wednesdays and this change will be in the next 22.1 prerelease. |
|
Thank you, I'll report back! |
|
Just wanted to report back this significantly improves things, thank you! Local build (all 37-locales): 104s → 33s Thanks so much, looking forward to the release! |
This refactors the i18n translation and locale inlining in the ESBuild pipeline to use
oxc-parserandmagic-stringinstead of@babel/core.By using the lightweight AST and precise token spans provided by OXC, we are able to perform
$localizeinlining and locale name replacements via targetedmagic-stringoverwrites in-place. This completely removes the dependency on@babel/coreand the custom/upstream Babel plugins in the worker, yielding faster startup times and significant compile-time speedups for localized builds.